﻿using System;
using System.Linq;

using FireBus.Contracts;
using FireBus.Isolation;


namespace FireBus.Core
{
	public class ExtensionAccessor : IExtensionAccessor
	{
		private readonly Host _Host;


		public ExtensionAccessor(Host host)
		{
			if (host == null)
			{
				throw new ArgumentNullException("host");
			}
			_Host = host;
		}


		public Object[] GetEventListeners(TypeName eventTypeName)
		{
			var extensions = _Host.GetEventListeners(eventTypeName);
			return extensions.ToArray();
		}


		public Object[] GetRequestListeners(TypeName requestTypeName, TypeName responseTypeName)
		{
			var extensions = _Host.GetRequestListeners(requestTypeName, responseTypeName);
			return extensions.ToArray();
		}
	}
}
